package com.example.logtest;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LoggerController {
    private static Logger logger = LoggerFactory.getLogger(LoggerController.class);

    @RequestMapping("/logger")
    public String logger() {
        logger.info("----------------输出的日志内容----------------");
        return "打印日志";
    }

    @RequestMapping("/printLogLevel")
    public String printLogLevel() {
        logger.trace("----------------trace----------------");
        logger.debug("----------------debug----------------");
        logger.info("----------------info----------------");
        logger.warn("----------------warn----------------");
        logger.error("----------------error----------------");
        return "打印不同级别的日志";
    }


    @RequestMapping("/slf4jTest")
    public String slf4jTest() {
        log.info("----------------slf4j test----------------");
        return "slf4j test";
    }
}
